package org.moyrax.nereyda.test
{
	import org.moyrax.nereyda.services.errors.ServiceError;
	
	import mx.utils.ObjectUtil;
	
	public class Debug
	{
		public static var debugEnabled :Boolean = true;
		
		public static function dump( error:ServiceError ):void
		{
			trace( "NAME: " + error.name );
			trace( "CODE: " + error.code );
			trace( "FILE: " + error.file );
			trace( "LINE: " + error.line );
			trace( "MESSAGE: " + error.message );
			trace( "TRACE: ");
			
			for each( var obj:Object in error.trace )
			{
				trace("\t------Stack Frame------");
				trace("\tFILE: " + obj.source );
				trace("\tLINE: " + obj.line );
				
				if ( obj["class"] ) {
					trace("\tSOURCE: " + obj["class"] + obj.type + obj["function"] + "()" );
				}
				else {
					trace("\tFUNCTION: " + obj["function"] + "()" );
				}
	
				var args:String = ObjectUtil.toString( obj.args );
				
				args = args.replace( /\n/ig, "\n\t\t" );
				
				trace("\tARGS:\n\t\t" + args );
			}
		}
		
		public static function print( object:Object ):void
		{
			trace( ObjectUtil.toString( object ) );
		}
	}
}